﻿
function Svn-Sync([string] $path) {
	$affected = 0
	$xml=[xml](svn status $path --xml -v)
	foreach ($target in $xml.status.target){
		foreach ($entry in $target.entry){
			if($target.path -eq $entry.path){
				write-host "WorkingCopy: " $entry.path
			} else {
				$state = $entry."wc-status".item
				switch ($state) {
					"unversioned" {
						svn add $entry.path
						$affected++
					}
					"modified"{
						$affected++
					}
					"added" {
						$affected++
					}
					"missing"{
						svn delete $entry.path
						$affected++
					}
					"deleted" {
						svn delete $entry.path
						$affected++
					}
				}
			}
		}
		if($affected -gt 0) {
			write-host Commiting  $affected items...
			svn commit $path -m "auto"
		} else {
			write-host Nothing to commit!
		}
	}
}


function Svn-Run([array] $a) {
	foreach ($path in $a) {
		if(Test-path $path){
			Svn-Sync($path)
		} else {
			write-host WorkingCopy-Path $path is not available!
		}
	}
}



